﻿using System;
using System.Windows.Markup;
using System.Windows.Data;
using DevExpress.Xpf.Grid;

namespace QuanLyKho.CommonControl
{
    public class ConvertCommon
    {
    }

    public class RowHandleToStringConverter : MarkupExtension, IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int rowHandle = System.Convert.ToInt32(value);

            if (rowHandle == GridControl.NewItemRowHandle || rowHandle == GridControl.AutoFilterRowHandle)
                return string.Empty;

            rowHandle++;
            return rowHandle.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
}
